﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PercolationTree.Model
{
    enum NodeType { Valid = 0, Invalid };

    class Node
    {
        #region Private
        private WeakReference<Node> m_Supernode;
        private IList<Node> m_Subnodes;
        #endregion

        #region Ctors
        public Node()
        {
            m_Subnodes = new List<Node>();
        }
        #endregion

        #region Public
        public NodeType Type { get; set; }
        public Node Supernode
        { 
            get
            {
                Node supernode;
                if (m_Supernode != null && m_Supernode.TryGetTarget(out supernode))
                    return supernode;
                else
                    return null;
            }
            set
            {
                m_Supernode = new WeakReference<Node>(value);
            }
        }
        public IList<Node> Subnodes { get { return m_Subnodes; } }
        #endregion
    }
}
